package com.lgkj.ui.userinfo;

import android.widget.TextView;

import com.google.gson.Gson;
import com.lgkj.R;
import com.lgkj.bean.meitao.IncomeBean;
import com.lgkj.ui.BaseActivity;
import com.lgkj.utils.CommonConstant;
import com.lgkj.utils.HttpUtils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/8/20 0020.
 */

public class IncomeActivity extends BaseActivity {


    @BindView(R.id.tv_huiyuan1)
    TextView tvHuiyuan1;
    @BindView(R.id.tv_dianshang1)
    TextView tvDianshang1;
    @BindView(R.id.tv_guagngao1)
    TextView tvGuagngao1;
    @BindView(R.id.tv_huiyuan2)
    TextView tvHuiyuan2;
    @BindView(R.id.tv_dianshang2)
    TextView tvDianshang2;
    @BindView(R.id.tv_guagngao2)
    TextView tvGuagngao2;
    @BindView(R.id.tv_huiyuan3)
    TextView tvHuiyuan3;
    @BindView(R.id.tv_dianshang3)
    TextView tvDianshang3;
    @BindView(R.id.tv_guagngao3)
    TextView tvGuagngao3;
    private String income_total = "0";
    private IncomeBean bean;
    @Override
    public int getLayoutId() {
        return R.layout.activity_income;
    }

    @Override
    public void initView() {
        setTitle("收益详情");
    }

    @Override
    public void initData() {
        Map<String, String> map = new HashMap<>();
        map.put("access_token", getToken());
        HttpUtils.postHttp(map, CommonConstant.getProfitInfo, new HttpUtils.HttpCallBack() {
            @Override
            public void successHttp(JSONObject jsonObject, int id) {
                if (jsonObject.optInt("code") == 0) {
                    Gson mGson = new Gson();
                    bean = mGson.fromJson(String.valueOf(jsonObject), IncomeBean.class);
                    tvHuiyuan1.setText(bean.getData().getDay_sum().get_$1()+"");
                    tvDianshang1.setText(bean.getData().getDay_sum().get_$2()+"");
                    tvGuagngao1.setText(bean.getData().getWeek_sum().get_$3()+"");

                    tvHuiyuan2.setText(bean.getData().getWeek_sum().get_$1()+"");
                    tvDianshang2.setText(bean.getData().getWeek_sum().get_$2()+"");
                    tvGuagngao2.setText(bean.getData().getDay_sum().get_$3()+"");

                    tvHuiyuan3.setText(bean.getData().getMonth_sum().get_$1()+"");
                    tvDianshang3.setText(bean.getData().getMonth_sum().get_$2()+"");
                    tvGuagngao3.setText(bean.getData().getMonth_sum().get_$3()+"");
                } else {
                    toastLong(jsonObject.optString("msg"), 0);
                }
            }

            @Override
            public void errorHttp(String msg) {

            }
        });
    }

}
